package com.yugao.fintech.vctgone.mybatisplus.config;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import com.yugao.fintech.vctgone.mybatisplus.handler.PiMetaObjectHandler;
import com.yugao.fintech.vctgone.mybatisplus.handler.SecurityMetaObjectHandler;
import com.yugao.fintech.vctgone.security.config.ResourceServerConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingClass;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;

@Configuration
@Import(MyBatisPlusConfig.class)
public class MyBatisPlusAutoConfiguration {
    @Bean
    @ConditionalOnMissingClass("com.yugao.fintech.vctgone.security.config.ResourceServerConfiguration")
    public MetaObjectHandler piMetaObjectHandler(){
        return new PiMetaObjectHandler();
    }

    @Bean
    @ConditionalOnClass(ResourceServerConfiguration.class)
    public MetaObjectHandler securityMetaObjectHandler(){
        return new SecurityMetaObjectHandler();
    }
}
